<?php

namespace App\Admin\Extensions;

use Encore\Admin\Admin;

class ChannelSysDetail
{
    protected $id;

    public function __construct($id, $date)
    {
        $this->id = $id;
        $this->date = $date;
    }

    protected function script()
    {
        return <<<SCRIPT

layui.use('layer', function(){
        var layer = layui.layer;
        $('.dispay').click(function () {
           var that = this;
           var id = $(that).attr('data-id');
           var date = $(that).attr('data-date');
           var index = layer.open({
               type: 2,
               content: '/html/channel/report_detail.html?id='+id+'&date='+date,
               area: ['80%', '70%'],
               yes: function(index, layero){
                   layer.close(index);
               }
           });
       });
    });
SCRIPT;
    }

    protected function render()
    {
        Admin::script($this->script());

        return "<a class='btn dispay btn-xs btn-success fa grid-check-row' data-date='{$this->date}' data-id='{$this->id}'>查看</a>";
    }

    public function __toString()
    {
        return $this->render();
    }
}